<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<#include "../../base/_meta.html"> 
<@head>

<script type="text/javascript">
// temp function
function addClick(item){
	var url="/auth/user/g2add";
	$.ligerDialog.open({ url: url, height: 400,width: 500,
		title:"添加用户"});
	
}
// modify
function modifyClick(item){
	var sRow = g.getSelectedRows();
	if(sRow.length == 0){
		$.ligerDialog.warn('请至少选择一行进行编辑。');
	}else if(sRow.length > 1){
		$.ligerDialog.warn('请选择一行进行编辑，您选择了【'+sRow.length+'】行。');
	}else{
		var key = sRow[0].loginaccount;
		var url="/auth/user/g2edit?loginaccount="+key;
		$.ligerDialog.open({ url: url, height: 400,width: 500,
			title:"修改用户"});
	}
}
//delete 
function deleteClick(){
	var sRow = g.getSelectedRows();
	if(sRow.length == 0){
		$.ligerDialog.warn('请至少选择一行进行删除。');
	}else{
		var keys="";
		for(var i=0;i<sRow.length;i++){
			keys += sRow[i].loginaccount+",";
		}		
		keys =keys.substring(0,keys.length-1);// remove last ',' 
		$.ligerDialog.confirm('您确定要删除选择的【'+sRow.length+'】条数据吗？', 
			function (yes) { 
				if(yes){
					$.ajax({
						url:"/auth/user/delete?keys="+keys,
						success:function(msg){
				        	if(msg >= 1){
				        		doSearch();
				        	}else{
				        		$.ligerDialog.error('删除数据失败。') 
				        	}
				    	}
					});	
				}
		});		
	}
}
// init liger ui 
$(function ()
{
	var items=[ { text: '账号或姓名', type:"textbox", id:'xm',name:'xm' },
	            { text: '查询',click: doSearch, icon: 'search' },
                { line: true },
	            { text: '增加', click: addClick, icon: 'add' },
                { line: true },
                { text: '修改', click: modifyClick, icon: 'modify' },
                { line: true },
                { text: '删除', click: deleteClick, icon: 'delete' }];
	 $("#toolbar").ligerToolBar({
		items: items
	 });
	 
    window['g'] =
    $("#maingrid").ligerGrid({
        height: '98%',
        checkbox: true,
        columns: [
        { display: '登陆账号', name: 'loginaccount',  width: 100, minWidth: 60 },
        { display: '显示名称', name: 'displayname', width: 120 },
        { display: '性别', name: 'sex', width: 80,render: f_renderSex },
        { display: '备注', name: 'remark',width: 170 }
        ], url: '/auth/user/pagenate', 
        pageSize: 10, rownumbers: true
    });
    $("#pageloading").hide();
});
// reload table
function queryForm(){
	var manager = $("#maingrid").ligerGetGridManager();
	manager.loadData(true);
}
// reload table
function doSearch(){
	var name=$("#xm").val();
	g.set({url:"/auth/user/pagenate?xm="+name});
	g.reload();
}
</script>
</@head>
<body style="overflow-x: hidden; padding: 2px;">
	<div class="l-loading" style="display: block" id="pageloading"></div>
	<div class="l-clear"></div>
	<div id="toolbar"></div>
	<div id="maingrid"></div>
	<div style="display: none;"></div>
</body>
</html>